package com.kinghood.productcenter.common.model.enums.product;

import lombok.Getter;

import java.util.Objects;

@Getter
public enum BusinessLogOperateEnum {

    ADD(1, "新增产品"),
    UPDATE(2, "修改产品"),
    SET_LABEL(3, "设置标签"),
    UPDATE_STATUS(4, "修改状态"),
    IMPORT_PICTURE(5, "导入款式图片"),
    UPLOAD_STYLE(6, "Excel导入款式"),
    UPLOAD_SKU(7, "Excel导入SKU"),
    ;

    private Integer type;
    private String name;

    BusinessLogOperateEnum(Integer type, String name) {
        this.type = type;
        this.name = name;
    }

    public static Integer getTypeByName(String name) {
        for (BusinessLogOperateEnum e : values()) {
            if (Objects.equals(name, e.getName())) {
                return e.getType();
            }
        }
        return null;
    }

    public static String getNameByType(Integer type) {
        for (BusinessLogOperateEnum e : values()) {
            if (Objects.equals(type, e.getType())) {
                return e.getName();
            }
        }
        return null;
    }
}
